/**
 * 
 */
package edu.rice.myxo.utils;

/**
 * @author frogy
 *
 */
public class SyncInt {
	int value;
	int[] l;
	
	public SyncInt(int threadN){
		l = new int[threadN];
		for(int i = 0; i < l.length; i++){
			l[i] = 0;
		}
		value = 0;
	}
	
	public void add(int threadId, int v){
		l[threadId] += v;
	}
	
	public void subtract(int threadId, int v){
		l[threadId] -= v;
	}
	
	public int getValue(){
		value = 0;
		for(int i =0 ; i < l.length; i++){
			value += l[i];
		}
		return value;
	}
}
